set -e

size=48

for dataset_name in \
    AbdomenCT1K \
    FLARE_2023 \
    KiTS23 \
    LUNA16 \
    Sarcopenia
do
    echo "Processing $dataset_name"
    target_dir="/home/zhangyq.sx/mgam_datasets/${dataset_name}_Data/spacing2_crop${size}_ccm0.9_npz/"
    echo "Writting to $target_dir"
    if [ -d "$target_dir" ]; then
        rm -r "$target_dir"
    fi
    precrop \
        /home/zhangyq.sx/mgam_datasets/${dataset_name}_Data/spacing2_mha/ \
        $target_dir \
        --crop-cat-max 0.9 \
        --crop-size $size $size $size \
        --mp
done

# Totalsegmentator Dataset
echo "Processing Totalsegmentator"
target_dir="/home/zhangyq.sx/mgam_datasets/Totalsegmentator_Data/spacing2_crop${size}_ccm0.9_npz/"
if [ -d "$target_dir" ]; then
    rm -r "$target_dir"
fi
python /home/zhangyq.sx/mgam_repos/mgam_datatoolkit/mgamdata/dataset/Totalsegmentator/precrop_npz.py \
        /home/zhangyq.sx/mgam_datasets/Totalsegmentator_Data/spacing2_mha/ \
        $target_dir \
        --crop-cat-max 0.9 \
        --crop-size $size $size $size \
        --mp
